package datasource.review;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import thesis.DataObject;

import datasource.image.ImageObj;
import experiment.Dimension;
import experiment.MainExp;

public class ReviewExp {

	private static List<Dimension> generateDim(ArrayList<ReviewObject> objs) {
		Dimension timeDim = new Dimension();
		Dimension rateDim = new Dimension();
		Dimension topicDim = new Dimension();

		for (ReviewObject obj : objs) {
			// time ------------

			HashMap<Long, Double> timeValue = timeDim.value2obj.get(""
					+ obj.timeCluster);
			if (timeValue == null) {
				timeValue = new HashMap<Long, Double>();
				timeDim.value2obj.put("" + obj.timeCluster, timeValue);
			}
			timeValue.put(obj.getDbId(), 1.0);

			// rating -----------
			HashMap<Long, Double> rateValue = rateDim.value2obj.get(""
					+ obj.rating);
			if (rateValue == null) {
				rateValue = new HashMap<Long, Double>();
				rateDim.value2obj.put("" + obj.rating, rateValue);
			}
			rateValue.put(obj.getDbId(), 1.0);
			// topic concepts -----------
			for (String concept : obj.topic.keySet()) {
				double prob = obj.topic.get(concept);
				HashMap<Long, Double> topicValue = topicDim.value2obj
						.get(concept);
				if (topicValue == null) {
					topicValue = new HashMap<Long, Double>();
					topicDim.value2obj.put(concept, topicValue);
				}
				topicValue.put(obj.getDbId(), prob);
			}

		}
		List<Dimension> dimensions = new ArrayList<Dimension>();
		dimensions.add(timeDim);
		dimensions.add(rateDim);
		dimensions.add(topicDim);
		topicDim.xor = false;
		return dimensions;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayList<ReviewObject> objs = new ArrayList();
		int numObj = 200;
		for (int i = 0; i < numObj; i++) {
			objs.add(new ReviewObject(i));
		}
		List<Dimension> dims = generateDim(objs);
		HashMap<Long, DataObject> objects = new HashMap<Long, DataObject>();
		for (ReviewObject obj : objs) {
			objects.put(obj.getDbId(), obj);
		}
		ArrayList<Double> weights = new ArrayList<Double>();
		for (int i = 0; i < dims.size(); i++) {
			weights.add(1.0);
		}
		MainExp.runSummarizer(objects, dims, weights, 0.0, 0.0, 1);

	}

}
